package monster.com.cvh.activity;

import android.content.res.Resources;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import monster.com.cvh.R;
import monster.com.cvh.activity.base.PermissionActivity;
import monster.com.cvh.fragment.ResumeShopFragment;
import monster.com.cvh.util.MyConstant;

/**
 * @author: 13580
 * @data: 2018/4/10
 * @function:商城模板Activity
 */
public class ResumeTemplateShopActivity extends PermissionActivity {

    @BindView(R.id.tv_include_top_bar_title)
    TextView mTvTitle;
    @BindView(R.id.tv_include_top_bar_save)
    TextView mTvAction;
    @BindView(R.id.tablayout_activity_resume_template_shop)
    SlidingTabLayout mTabLayout;
    @BindView(R.id.viewpager_activity_resume_template_shop)
    ViewPager mViewPager;

    private List<Fragment> mFragments = new ArrayList<>();
    private FragmentPagerAdapter mAdapter;
    private String[] mTabTitle;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_resume_template_shop;
    }

    @Override
    protected void initEvent() {
        changeStatusBarColorDark(ResumeTemplateShopActivity.this, R.color.white);
        mTvTitle.setText(getResources().getString(R.string.fragment_user_reseume_download_title));
        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragments.get(position);
            }

            @Override
            public int getCount() {
                return mFragments.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return mTabTitle[position];
            }
        };
        mViewPager.setAdapter(mAdapter);
        //page保活数
        mViewPager.setOffscreenPageLimit(4);
        mTabLayout.setViewPager(mViewPager,mTabTitle);
        mTvAction.setVisibility(View.GONE);

    }

    @Override
    protected void initData() {
        mTabTitle = new String[]{
                getResources().getString(R.string.fragment_user_reseume_download_tab_latest),
                getResources().getString(R.string.fragment_user_reseume_download_tab_free),
                getResources().getString(R.string.fragment_user_reseume_download_tab_pay)
        };
        mFragments.add(ResumeShopFragment.newInstance(MyConstant.RESUME_TYPE_NEW));
        mFragments.add(ResumeShopFragment.newInstance(MyConstant.RESUME_TYPE_FREE));
        mFragments.add(ResumeShopFragment.newInstance(MyConstant.RESUME_TYPE_ADVANCED));
    }

    @OnClick(R.id.iv_include_top_bar_back)
    public void onViewClicked() {
        finish();
    }
}
